<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
    '<div contenteditable>abc<i>de ef</i> gh <b> i|j </b> kl</div>',
    'delete',
    '<div contenteditable>abc<i>de ef</i> gh |<b>j </b> kl</div>'),
    'Delete a character also removes redundant whitespaces');

test(() => assert_selection(
    '<div contenteditable>abc<i>de ef</i> gh <b> ^ij| </b> kl</div>',
    'delete',
    '<div contenteditable>abc<i>de ef</i> gh |<b>\u{00A0}</b>kl</div>'),
    'Delete characters and fix up whitespaces');

test(() => assert_selection(
    '<div contenteditable>bar ^baz|<span>    </span>foo</div>',
    'delete',
    '<div contenteditable>bar |<span>\u{00A0}</span>foo</div>'),
    'Delete characters and convert SPACEs to NBSP');

test(() => assert_selection(
    '<div contenteditable>bar ^baz|<span> \u{00A0} </span>foo</div>',
    'delete',
    '<div contenteditable>bar |<span>\u{00A0} \u{00A0}</span>foo</div>'),
    'Delete characters and convert NBSP+SPACEs to NBSPs+SPACE');
</script>
